<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的兑换 - 模切材料小管家</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            /* TDesign 工业品色彩系统 */
            --primary-color: #0052d9;
            --primary-light: #266fe8;
            --primary-dark: #003cab;
            --secondary-color: #f2f3ff;
            --accent-color: #e37318;
            --success-color: #00a870;
            --warning-color: #ed7b2f;
            --error-color: #d54941;
            
            /* 背景色系 */
            --bg-color-page: #f5f7fa;
            --bg-color-container: #ffffff;
            --bg-color-secondray: #f8f9fc;
            
            /* 边框和分割线 */
            --border-color: #e7e7e7;
            --border-color-light: #f0f0f0;
            --border-radius-small: 3px;
            --border-radius-medium: 6px;
            --border-radius-large: 9px;
            
            /* 文字色彩 */
            --text-primary: #1a1a1a;
            --text-secondary: #4e5969;
            --text-placeholder: #86909c;
            --text-disabled: #c9cdd4;
            
            /* 阴影系统 */
            --shadow-1: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
            --shadow-2: 0 1px 4px 0 rgba(0, 0, 0, 0.08);
            --shadow-3: 0 4px 8px 0 rgba(0, 0, 0, 0.12);
            
            /* 间距系统 */
            --space-1: 4px;
            --space-2: 8px;
            --space-3: 12px;
            --space-4: 16px;
            --space-5: 20px;
            --space-6: 24px;
            --space-8: 32px;
            --space-10: 40px;
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
        }
        
        body {
            background-color: var(--bg-color-page);
            color: var(--text-primary);
            font-size: 14px;
            line-height: 1.5;
            padding-bottom: 64px;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
        }
        
        .container {
            max-width: 480px;
            margin: 0 auto;
            background: var(--bg-color-container);
            min-height: 100vh;
            box-shadow: var(--shadow-1);
            position: relative;
            overflow-x: hidden;
        }
        
        /* 头部样式 */
        .header {
            background: var(--primary-color);
            color: white;
            padding: var(--space-4);
            position: relative;
            z-index: 10;
        }
        
        .top-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .back-btn {
            font-size: 18px;
            cursor: pointer;
            opacity: 0.9;
            transition: opacity 0.2s ease;
        }
        
        .back-btn:hover {
            opacity: 1;
        }
        
        .page-title {
            font-weight: 500;
            font-size: 16px;
        }
        
        .actions {
            display: flex;
            gap: var(--space-4);
        }
        
        .actions i {
            font-size: 16px;
            cursor: pointer;
            opacity: 0.9;
            transition: opacity 0.2s ease;
        }
        
        .actions i:hover {
            opacity: 1;
        }
        
        /* 筛选区域 */
        .filter-section {
            background: var(--bg-color-container);
            padding: var(--space-3) var(--space-4);
            margin-bottom: var(--space-2);
            border-bottom: 1px solid var(--border-color-light);
        }
        
        .filter-tabs {
            display: flex;
            gap: var(--space-2);
        }
        
        .filter-tab {
            padding: var(--space-2) var(--space-3);
            border: 1px solid var(--border-color-light);
            border-radius: var(--border-radius-medium);
            background: var(--bg-color-secondray);
            color: var(--text-secondary);
            font-size: 12px;
            cursor: pointer;
            transition: all 0.2s ease;
            white-space: nowrap;
        }
        
        .filter-tab.active {
            background: var(--primary-color);
            color: white;
            border-color: var(--primary-color);
        }
        
        .filter-tab:hover {
            background: var(--primary-light);
            color: white;
        }
        
        /* 兑换记录列表 */
        .exchanges-section {
            padding: var(--space-4);
        }
        
        .section-title {
            font-size: 14px;
            font-weight: 500;
            margin-bottom: var(--space-4);
            color: var(--text-primary);
            display: flex;
            align-items: center;
        }
        
        .section-title i {
            margin-right: var(--space-2);
            color: var(--accent-color);
            font-size: 14px;
        }
        
        .exchanges-list {
            display: flex;
            flex-direction: column;
            gap: var(--space-3);
        }
        
        .exchange-item {
            background: var(--bg-color-container);
            border-radius: var(--border-radius-medium);
            padding: var(--space-4);
            box-shadow: var(--shadow-1);
            cursor: pointer;
            transition: all 0.2s cubic-bezier(0.34, 0.69, 0.1, 1);
            border: 1px solid var(--border-color-light);
            position: relative;
            overflow: hidden;
        }
        
        .exchange-item::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 3px;
            height: 100%;
            background: var(--accent-color);
            border-radius: var(--border-radius-medium) 0 0 var(--border-radius-medium);
        }
        
        .exchange-item:hover {
            border-color: var(--primary-color);
            box-shadow: var(--shadow-2);
        }
        
        .exchange-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-bottom: var(--space-3);
        }
        
        .exchange-product {
            flex: 1;
        }
        
        .product-name {
            font-weight: 500;
            font-size: 14px;
            color: var(--text-primary);
            margin-bottom: var(--space-1);
        }
        
        .product-category {
            font-size: 12px;
            color: var(--text-placeholder);
        }
        
        .exchange-status {
            font-size: 12px;
            padding: var(--space-1) var(--space-2);
            border-radius: var(--border-radius-small);
            font-weight: 500;
        }
        
        .status-pending {
            background: #fff7e6;
            color: var(--warning-color);
        }
        
        .status-shipped {
            background: #e6f7ff;
            color: var(--primary-color);
        }
        
        .status-completed {
            background: #f6ffed;
            color: var(--success-color);
        }
        
        .exchange-details {
            display: flex;
            flex-direction: column;
            gap: var(--space-2);
        }
        
        .detail-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 12px;
        }
        
        .detail-label {
            color: var(--text-placeholder);
            min-width: 60px;
        }
        
        .detail-value {
            color: var(--text-secondary);
            flex: 1;
            text-align: right;
        }
        
        .points-value {
            color: var(--accent-color);
            font-weight: 600;
        }
        
        .exchange-time {
            color: var(--text-placeholder);
            font-size: 11px;
            margin-top: var(--space-2);
            text-align: right;
        }
        
        /* 空状态 */
        .empty-state {
            text-align: center;
            padding: var(--space-10);
            color: var(--text-secondary);
        }
        
        .empty-state i {
            font-size: 48px;
            margin-bottom: var(--space-4);
            opacity: 0.5;
            color: var(--text-placeholder);
        }
        
        .empty-title {
            font-size: 16px;
            margin-bottom: var(--space-2);
        }
        
        .empty-desc {
            font-size: 14px;
            opacity: 0.8;
        }
        
        /* 底部导航 */
        .tabbar {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            background: var(--bg-color-container);
            border-top: 1px solid var(--border-color);
            display: flex;
            z-index: 100;
            max-width: 480px;
            margin: 0 auto;
            height: 64px;
        }
        
        .tab-item {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: var(--space-2) 0;
            cursor: pointer;
            transition: color 0.2s ease;
            color: var(--text-placeholder);
        }
        
        .tab-item.active {
            color: var(--primary-color);
        }
        
        .tab-item:hover {
            color: var(--primary-light);
        }
        
        .tab-item i {
            font-size: 18px;
            margin-bottom: var(--space-1);
        }
        
        .tab-item span {
            font-size: 10px;
        }
    </style>
</head>
<body>
    <div class="container">
        <!-- 头部区域 -->
        <div class="header">
            <div class="top-bar">
                <div class="back-btn" onclick="history.back()">
                    <i class="fas fa-arrow-left"></i>
                </div>
                <div class="page-title">我的兑换</div>
                <div class="actions">
                    <i class="fas fa-search" onclick="searchExchanges()"></i>
                </div>
            </div>
        </div>
        
        <!-- 筛选区域 -->
        <div class="filter-section">
            <div class="filter-tabs">
                <div class="filter-tab active" data-status="all" onclick="filterByStatus('all')">全部</div>
                <div class="filter-tab" data-status="pending" onclick="filterByStatus('pending')">待发货</div>
                <div class="filter-tab" data-status="shipped" onclick="filterByStatus('shipped')">已发货</div>
                <div class="filter-tab" data-status="completed" onclick="filterByStatus('completed')">已完成</div>
            </div>
        </div>
        
        <!-- 兑换记录列表 -->
        <div class="exchanges-section">
            <div class="section-title">
                <i class="fas fa-gift"></i>
                兑换记录
            </div>
            <div class="exchanges-list" id="exchangesList">
                <!-- 兑换记录将通过JavaScript动态生成 -->
            </div>
        </div>
        
        <!-- 底部导航 -->
        <div class="tabbar">
            <div class="tab-item" onclick="location.href='home.html'">
                <i class="fas fa-home"></i>
                <span>首页</span>
            </div>
            <div class="tab-item" onclick="location.href='demand-list.html'">
                <i class="fas fa-search"></i>
                <span>求购</span>
            </div>
            <div class="tab-item" onclick="location.href='publish-select.html'">
                <i class="fas fa-plus-circle"></i>
                <span>发布</span>
            </div>
            <div class="tab-item" onclick="location.href='consultation.html'">
                <i class="fas fa-comments"></i>
                <span>客服</span>
            </div>
            <div class="tab-item active" onclick="location.href='profile.html'">
                <i class="fas fa-user"></i>
                <span>我的</span>
            </div>
        </div>
    </div>
    
    <script>
        // 兑换记录数据
        const exchanges = [
            {
                id: 1,
                productName: "得力文具套装",
                category: "办公用品",
                points: 500,
                exchangeTime: "2024-01-15 14:30",
                status: "completed",
                recipientName: "蒋婷",
                recipientPhone: "138****8888",
                recipientAddress: "上海市浦东新区张江高科技园区",
                trackingNumber: "SF1234567890"
            },
            {
                id: 2,
                productName: "小米无线鼠标",
                category: "办公用品",
                points: 800,
                exchangeTime: "2024-01-12 09:15",
                status: "shipped",
                recipientName: "蒋婷",
                recipientPhone: "138****8888",
                recipientAddress: "上海市浦东新区张江高科技园区",
                trackingNumber: "SF1234567891"
            },
            {
                id: 3,
                productName: "三只松鼠坚果礼盒",
                category: "健康食品",
                points: 300,
                exchangeTime: "2024-01-10 16:45",
                status: "completed",
                recipientName: "蒋婷",
                recipientPhone: "138****8888",
                recipientAddress: "上海市浦东新区张江高科技园区",
                trackingNumber: "SF1234567892"
            },
            {
                id: 4,
                productName: "Excel办公技能培训",
                category: "培训活动",
                points: 1000,
                exchangeTime: "2024-01-08 11:20",
                status: "pending",
                recipientName: "蒋婷",
                recipientPhone: "138****8888",
                recipientAddress: "上海市浦东新区张江高科技园区",
                trackingNumber: null
            },
            {
                id: 5,
                productName: "蒙牛特仑苏牛奶",
                category: "健康食品",
                points: 200,
                exchangeTime: "2024-01-05 13:10",
                status: "completed",
                recipientName: "蒋婷",
                recipientPhone: "138****8888",
                recipientAddress: "上海市浦东新区张江高科技园区",
                trackingNumber: "SF1234567893"
            },
            {
                id: 6,
                productName: "密室逃脱体验券",
                category: "团建活动",
                points: 400,
                exchangeTime: "2024-01-03 15:30",
                status: "shipped",
                recipientName: "蒋婷",
                recipientPhone: "138****8888",
                recipientAddress: "上海市浦东新区张江高科技园区",
                trackingNumber: "SF1234567894"
            }
        ];
        
        // 当前筛选状态
        let currentFilter = 'all';
        
        // 状态映射
        const statusMap = {
            pending: { text: '待发货', class: 'status-pending' },
            shipped: { text: '已发货', class: 'status-shipped' },
            completed: { text: '已完成', class: 'status-completed' }
        };
        
        // 初始化页面
        function initPage() {
            renderExchanges();
        }
        
        // 渲染兑换记录列表
        function renderExchanges() {
            const list = document.getElementById('exchangesList');
            const filteredExchanges = currentFilter === 'all' 
                ? exchanges 
                : exchanges.filter(e => e.status === currentFilter);
            
            if (filteredExchanges.length === 0) {
                list.innerHTML = `
                    <div class="empty-state">
                        <i class="fas fa-gift"></i>
                        <div class="empty-title">暂无兑换记录</div>
                        <div class="empty-desc">${currentFilter === 'all' ? '您还没有兑换过任何商品' : '该状态下暂无兑换记录'}</div>
                    </div>
                `;
                return;
            }
            
            list.innerHTML = filteredExchanges.map(exchange => {
                const statusInfo = statusMap[exchange.status];
                
                return `
                    <div class="exchange-item" onclick="viewExchangeDetail(${exchange.id})">
                        <div class="exchange-header">
                            <div class="exchange-product">
                                <div class="product-name">${exchange.productName}</div>
                                <div class="product-category">${exchange.category}</div>
                            </div>
                            <div class="exchange-status ${statusInfo.class}">${statusInfo.text}</div>
                        </div>
                        <div class="exchange-details">
                            <div class="detail-row">
                                <span class="detail-label">兑换积分</span>
                                <span class="detail-value points-value">${exchange.points} 积分</span>
                            </div>
                            <div class="detail-row">
                                <span class="detail-label">收件人</span>
                                <span class="detail-value">${exchange.recipientName}</span>
                            </div>
                            <div class="detail-row">
                                <span class="detail-label">联系电话</span>
                                <span class="detail-value">${exchange.recipientPhone}</span>
                            </div>
                            <div class="detail-row">
                                <span class="detail-label">收货地址</span>
                                <span class="detail-value">${exchange.recipientAddress}</span>
                            </div>
                            ${exchange.trackingNumber ? `
                                <div class="detail-row">
                                    <span class="detail-label">快递单号</span>
                                    <span class="detail-value">${exchange.trackingNumber}</span>
                                </div>
                            ` : ''}
                        </div>
                        <div class="exchange-time">${exchange.exchangeTime}</div>
                    </div>
                `;
            }).join('');
        }
        
        // 按状态筛选
        function filterByStatus(status) {
            currentFilter = status;
            
            // 更新筛选标签状态
            document.querySelectorAll('.filter-tab').forEach(tab => {
                tab.classList.remove('active');
            });
            document.querySelector(`[data-status="${status}"]`).classList.add('active');
            
            // 重新渲染列表
            renderExchanges();
        }
        
        // 查看兑换详情
        function viewExchangeDetail(exchangeId) {
            const exchange = exchanges.find(e => e.id === exchangeId);
            if (exchange) {
                alert(`兑换详情：\n商品：${exchange.productName}\n积分：${exchange.points}\n状态：${statusMap[exchange.status].text}\n收件人：${exchange.recipientName}\n电话：${exchange.recipientPhone}\n地址：${exchange.recipientAddress}${exchange.trackingNumber ? `\n快递单号：${exchange.trackingNumber}` : ''}`);
            }
        }
        
        // 搜索兑换记录
        function searchExchanges() {
            const keyword = prompt('请输入商品名称或收件人姓名进行搜索：');
            if (keyword) {
                const filteredExchanges = exchanges.filter(e => 
                    e.productName.includes(keyword) || 
                    e.recipientName.includes(keyword)
                );
                
                if (filteredExchanges.length === 0) {
                    alert('未找到相关兑换记录');
                } else {
                    // 临时显示搜索结果
                    const list = document.getElementById('exchangesList');
                    list.innerHTML = filteredExchanges.map(exchange => {
                        const statusInfo = statusMap[exchange.status];
                        
                        return `
                            <div class="exchange-item" onclick="viewExchangeDetail(${exchange.id})">
                                <div class="exchange-header">
                                    <div class="exchange-product">
                                        <div class="product-name">${exchange.productName}</div>
                                        <div class="product-category">${exchange.category}</div>
                                    </div>
                                    <div class="exchange-status ${statusInfo.class}">${statusInfo.text}</div>
                                </div>
                                <div class="exchange-details">
                                    <div class="detail-row">
                                        <span class="detail-label">兑换积分</span>
                                        <span class="detail-value points-value">${exchange.points} 积分</span>
                                    </div>
                                    <div class="detail-row">
                                        <span class="detail-label">收件人</span>
                                        <span class="detail-value">${exchange.recipientName}</span>
                                    </div>
                                    <div class="detail-row">
                                        <span class="detail-label">联系电话</span>
                                        <span class="detail-value">${exchange.recipientPhone}</span>
                                    </div>
                                    <div class="detail-row">
                                        <span class="detail-label">收货地址</span>
                                        <span class="detail-value">${exchange.recipientAddress}</span>
                                    </div>
                                    ${exchange.trackingNumber ? `
                                        <div class="detail-row">
                                            <span class="detail-label">快递单号</span>
                                            <span class="detail-value">${exchange.trackingNumber}</span>
                                        </div>
                                    ` : ''}
                                </div>
                                <div class="exchange-time">${exchange.exchangeTime}</div>
                            </div>
                        `;
                    }).join('');
                }
            }
        }
        
        // 页面加载完成后初始化
        document.addEventListener('DOMContentLoaded', function() {
            initPage();
        });
    </script>
</body>
</html>
